package com.c.rabbit_mq.impl;

import cn.hutool.json.JSONUtil;
import com.c.rabbit_mq.ComRabbitMqHandle;
import com.modular.iot.bean.ThingsDeviceCmdDo;
import com.modular.iot.tool.ToolIotCmd;
import com.tool.rabbit.ToolRabbitMQ;

/**
 * 反控 mqtt 推送消息
 */
public class IotCmdExe extends ComRabbitMqHandle<ThingsDeviceCmdDo> {

    public static final String TOPIC = "/com-server/cmd-exe";

    public IotCmdExe() {
        super(TOPIC, ThingsDeviceCmdDo.class);
    }

    @Override
    public void handle(String topic, ThingsDeviceCmdDo thingsDeviceCmdDo) {
        ToolIotCmd.exeCmd(thingsDeviceCmdDo);
    }

    public static void push(ThingsDeviceCmdDo thingsDeviceCmdDo) {
        ToolRabbitMQ.push(TOPIC, JSONUtil.toJsonStr(thingsDeviceCmdDo));
    }

}
